package day5;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;

/**
 * ClassName：TestBuffendChar
 *
 * @Author：小鱼
 * @Create：2025-08-22 9:41
 */
public class TestBufferedChar {
    //字符缓冲流
    public static void main(String[] args) throws Exception{
        BufferedReader br = new BufferedReader(new FileReader("D:\\IDEA_project\\JP_Java\\week6\\src\\day5\\1.txt "));
        BufferedWriter bw = new BufferedWriter(new FileWriter("D:\\IDEA_project\\JP_Java\\week6\\src\\day5\\2.txt "));
        //逐行读取
        String line;
        while ((line = br.readLine())!=null){
            //输出数据
            System.out.println("line: "+line);
            //写入
//            if(br.ready()){
//                bw.write(line+"\n");
//            }else {
//                bw.write(line);
//            }

            bw.write(line);
            if(br.ready()){
                bw.newLine();//写入一个换行符
            }



        }
        //关闭资源
        bw.close();
        br.close();
    }
}
